//
// Copyright 2017 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions://
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@import "../../packages/mdc-animation/functions";
@import "../../packages/mdc-button/mdc-button";
@import "../../packages/mdc-card/mdc-card";
@import "../../packages/mdc-checkbox/mdc-checkbox";
@import "../../packages/mdc-dialog/mdc-dialog";
@import "../../packages/mdc-drawer/mdc-drawer";
@import "../../packages/mdc-elevation/mdc-elevation";
@import "../../packages/mdc-fab/mdc-fab";
@import "../../packages/mdc-form-field/mdc-form-field";
@import "../../packages/mdc-icon-button/mdc-icon-button";
@import "../../packages/mdc-linear-progress/mdc-linear-progress";
@import "../../packages/mdc-list/mdc-list";
@import "../../packages/mdc-menu/mdc-menu";
@import "../../packages/mdc-menu-surface/mdc-menu-surface";
@import "../../packages/mdc-radio/mdc-radio";
@import "../../packages/mdc-ripple/mdc-ripple";
@import "../../packages/mdc-select/mdc-select";
@import "../../packages/mdc-slider/mdc-slider";
@import "../../packages/mdc-switch/mdc-switch";
@import "../../packages/mdc-tabs/mdc-tabs";
@import "../../packages/mdc-textfield/mdc-text-field";
@import "../../packages/mdc-theme/color-palette";
@import "../../packages/mdc-theme/mixins";
@import "../../packages/mdc-theme/variables";
@import "../../packages/mdc-toolbar/variables";
@import "../common";
@import "./menu";

// stylelint-disable selector-class-pattern, selector-max-type, scss/dollar-variable-pattern

$demo-toolbar-progress-bar-color: secondary !default;
$demo-toolbar-progress-buffer-color: primary !default;

$demo-section-margin: 48px;

$demo-color-custom: $material-color-red-500;
$demo-color-low-luminance: $material-color-brown-900;
$demo-color-high-luminance: $material-color-amber-50;

//
// Global styles
//

body {
  color: mdc-theme-accessible-ink-color($mdc-theme-background);
  background-color: $mdc-theme-background;
}

figure {
  margin-left: 0;
  margin-right: 0;
}

//
// Toolbar
//

.demo-toolbar-progress-row {
  min-height: auto;
  overflow: hidden;
  position: absolute;
  bottom: 0;
}

.demo-toolbar-progress-bar {
  transform: translateY(100%);
  transition: mdc-animation-exit-temporary(transform, 150ms);

  @include mdc-linear-progress-bar-color($demo-toolbar-progress-bar-color);
  @include mdc-linear-progress-buffer-color($demo-toolbar-progress-buffer-color);
}

.demo-toolbar-progress-bar--active {
  transform: none;
  transition: mdc-animation-enter(transform, 200ms);
}

.demo-anchor-with-toolbar-offset {
  $margin: $demo-section-margin / 2;

  display: block;
  position: relative;
  top: -($mdc-toolbar-row-height + $margin);

  @media (max-width: $mdc-toolbar-mobile-landscape-width-breakpoint)
    and (orientation: landscape) {
    top: -($mdc-toolbar-mobile-landscape-row-height + $margin);
  }

  @media (max-width: $mdc-toolbar-mobile-breakpoint) {
    top: -($mdc-toolbar-mobile-row-height + $margin);
  }

  visibility: hidden;
}

//
// Page content
//

.demo-main {
  // Don't override padding-top, which is set by the fixed-adjust class
  padding-bottom: 24px;
  padding-right: 24px;
  padding-left: 24px;
}

.demo-component-section {
  position: relative;
}

.demo-component-section + .demo-component-section {
  margin-top: $demo-section-margin;
}

.demo-component-section::before {
  content: "";
  display: block;
  position: absolute;
  top: -16px;
  left: -16px;
  right: -16px;
  bottom: -16px;
  z-index: -1;
  background: $material-color-yellow-700;
  opacity: 0;
  transition: opacity 1s;
}

.demo-component-section--flash::before {
  opacity: 0.5;
  transition: none;
}

.demo-component-section__permalink {
  color: inherit;
  opacity: 0;

  .demo-component-section:hover &,
  .demo-component-section__heading--focus-within & {
    opacity: 1;
  }
}

//
// CSS class demo
//

.demo-theme-color-section + .demo-theme-color-section {
  margin-top: 36px;
}

.demo-theme-color-section__row {
  display: flex;
  flex-wrap: wrap;
}

.demo-fieldset--color {
  margin-right: 36px;
}

.demo-theme-color-group {
  padding: 16px 0;
}

.demo-theme-color-swatches {
  display: inline-flex;
  flex-direction: column;
  margin-right: 16px;
}

.demo-theme-color-swatch {
  @include mdc-elevation(1);

  display: inline-block;
  box-sizing: border-box;
  width: 150px;
  height: 50px;
  line-height: 50px;
  text-align: center;
  margin-bottom: 8px;
  border-radius: 4px;
}

.demo-theme-bg--low-luminance {
  background-color: $demo-color-low-luminance;
}

.demo-theme-bg--high-luminance {
  background-color: $demo-color-high-luminance;
}

.demo-theme-bg--custom-light {
  background-color: #dddddd;
}

.demo-theme-bg--custom-dark {
  background-color: #1d1d1d;
}

.demo-theme-text-row {
  display: inline-flex;
  box-sizing: border-box;
  padding: 16px;
  border: 1px solid #f0f0f0;
  align-items: center;
  flex-direction: column;
}

@media(min-width: 768px) {
  .demo-theme-text-row {
    flex-direction: row;
  }
}

.demo-theme-text-style {
  padding: 0 16px;
}

//
// Button demo
//

.demo-fieldset--button + .demo-fieldset--button {
  margin-top: 16px;
}

.demo-button__code {
  font-size: smaller;
  text-transform: none;
}

//
// Card demo
//

.demo-card-wrapper {
  display: inline-block;
  margin: 0 24px 24px 0;
  vertical-align: top;
}

.demo-card__media {
  background-image: url("/images/1-1.jpg");
}

.demo-card__media--16-9 {
  background-image: url("/images/16-9.jpg");
}

//
// Checkbox demo
//

.demo-checkbox-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.demo-checkbox-wrapper,
.demo-checkbox-toggle-button {
  margin-right: 10px;
}

.demo-checkbox-wrapper + .demo-checkbox-toggle-button {
  margin-left: 20px;
}

//
// Dialog demo
//

.demo-dialog {
  position: relative;
  justify-content: flex-start;
  z-index: auto;
}

//
// Drawer demo
//

.demo-drawer-toggle {
  @include mdc-states(on-primary);

  vertical-align: middle;
  cursor: pointer;
}

//
// Floating Action Button (FAB) demo
//

.demo-fab-row {
  display: flex;
  flex-wrap: wrap;
}

.demo-fab {
  margin: 16px 0 0 0;
}

.demo-fab-tile {
  margin: 0 48px 1em 0;
}

.demo-fab-tile__title {
  font-weight: 500;
}

.demo-fab-tile__snippet {
  height: 2em;
}

//
// Icon Toggle demo
//

.mdc-icon-button {
  // .material-icons and .mdc-icon-button each set different `display` values. Whichever CSS file is imported last
  // will win, so prevent them from fighting by specifying the value we want here.
  display: inline-flex;
}

.demo-icon-toggle-row {
  display: flex;
  flex-wrap: wrap;
}

.demo-icon-toggle-tile {
  width: 200px;
  margin: 0 10px 10px 0;
  padding: 20px;
  border-radius: 5px;
  text-align: center;
}

//
// Linear Progress demo
//

.demo-linear-progress-row {
  margin: 32px 0;
}

.demo-linear-progress-row + .demo-linear-progress-row {
  margin-top: 64px;
}

//
// Radio Button demo
//

.demo-radio-group {
  display: inline-block;
  margin: 0 24px 24px 0;
}

.demo-radio-form-field {
  margin-right: 8px;
}

//
// Switch demo
//

.demo-switch-wrapper {
  display: inline-block;
  margin: 16px 16px 0 0;
}

//
// Tab Bar demo
//

.demo-figure--tab-bar + .demo-figure--tab-bar {
  margin-top: 36px;
}

.demo-tab-bar {
  margin: 0;
}

//
// Text Field demo
//

.demo-text-field-wrapper {
  display: inline-block;
  margin: 16px 16px 0 0;
}

.demo-text-field {
  margin-top: 0 !important;
}
